﻿using Microsoft.Xaml.Behaviors.Layout;

using PLCS.Domain.Shared.Enums;
using PLCS.Shared.Common.Constant;

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace PLCS.App.EquipmentManager.Converts;

public class IntsToTrayTypesConvert : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        if (value is string trayTypes)
        {
            var stringTrayTypes = trayTypes
                .Split(ConstantChar.SplitChar)
                .Where(trayType => !string.IsNullOrEmpty(trayType))
                .Select(trayType => ((TrayType)int.Parse(trayType)).ToString())
                .ToList();

            return string.Join(ConstantChar.SplitChar.ToString(), stringTrayTypes);
        }

        return string.Empty;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return null;
    }
}